<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>按钮，按一下再加载b.js模块</button>
    <script type="module">
        // 取默认导出时，无需使用大括号
        import  obj, {a} from './a.js';
        console.log(obj);
        // 直接取
        console.log(obj.name, obj.age);
        // 解构赋值
        let {name, age} = obj;
        console.log(name, age);
        console.log(a);

        // 通配符取出
        import * as obj from './a.js';
        console.log(obj);
        console.log(obj.a);
        console.log(obj.default.name, obj.default.age);

        // 懒加载(按需加载)
        import './a.js';
        document.querySelector('button').onclick = function() {
            import('./b.js').then(cb => {
                console.log(cb);
            })
        }

    </script>
</body>
</html>